<template>
	<view class="content">
		<view class="poster" :style="'height:'+imageH+'px'">
			<image :src="posterImg"></image>
		</view>
		<view class="bot-space"></view>
		<view class="bot-space bot-tool">
			<view class="btn-box" @click="goSearchGood">
				<image :src="btnImg" mode="aspectFit" :style="'height:'+getBtnImgH+'px;width:'+getBtnImgW+'px'"></image>
				<view class="show-des">
					低至<text class="show-price">￥{{price}}</text>起
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import { HTTP_REQUEST_URL } from '@/config/app';
	import {familyDoctor} from '@/api/inquiry.js';
	import {
		mapGetters
	} from "vuex";
	export default {

		data(){
			return {
				searchVal:'',
				// posterImg: HTTP_REQUEST_URL + '/uni_static/i/test.jpg',
				posterImg:'',
				imageH:2600,
				price:0,
				btnImg:HTTP_REQUEST_URL + '/uni_static/i/i_open.png',
				canShow:false,
			}
		},
		computed:{
			...mapGetters(['routeError']),
			getBtnImgW(){
				let screenW = uni.getSystemInfoSync().screenWidth - 40;
				return screenW;
			},
			getBtnImgH(){
				let screenW = uni.getSystemInfoSync().screenWidth - 40;
				let imgH = screenW * 118.0/989;
				console.log('rk==>hh:'+imgH)
				return imgH;
			}
		},
		onLoad(ops) {
			if(this.routeError) {
				this.$store.commit('GO_ERROR');
				return
			}
			if(ops && ops.val) {
				this.searchVal = ops.val;
			}
			this.familyDoctor();
		},
		methods:{
			familyDoctor(){
				let that = this;
				familyDoctor().then(res=>{
					this.posterImg = res.data.pic;
					this.price = res.data.price;
					this.canShow = res.data.is_show;
					this.$nextTick(function() {
						that.calculationImg();
					})
				});
			},
			calculationImg(){
				let that = this;
				uni.getImageInfo({
					src: this.posterImg,
					success: function(res) {
						let realW = res.width;
						let realH = res.height;
						let screenW = uni.getSystemInfoSync().screenWidth;
						let showH = screenW*res.height/res.width;
						that.$set(that, 'imageH', showH);
						console.log('rk===>suc:'+JSON.stringify(res));
						console.log('rk===>show:'+showH);
					},
					fail: function(error) {
						that.$set(that, 'imageH', 2600);
						console.log('rk===>fail');
					}
				})
			},
			goSearchGood(){
				console.log('===>'+this.canShow)
				if(!this.canShow){
					this.$util.Tips({
						title:'家庭医生不存在,请联系管理'
					})
					return
				}
				uni.navigateTo({
					url: '/pages/columnGoods/goods_search_con/index?searchValue=' + this.searchVal
				})
			}
		}
	}
</script>

<style lang="scss">

	.content {
		
	}
	.poster {
		width: 100%;
		image {
			width: 100%;
			height: 100%;
		}
	}
	.bot-space{
		height: 150rpx;
		height: calc(150rpx + constant(safe-area-inset-bottom));
		height: calc(150rpx + env(safe-area-inset-bottom));
	}
	.bot-tool {
		position: fixed;
		bottom:0;
		background-color: #fff;
		width: 100%;
		.btn-box {
			width: 100%;
			height: 110rpx;
			display: flex;
			justify-content: center;
			align-items: center;
			position: relative;
			
			image {
				border-radius: 110rpx;
			}
			.show-des {
				position: absolute;
				left: 23%;
			}
			.show-price {
				color: #E87D4D;
			}
		}
	}

</style>